﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutofacContrib.DynamicProxy2;

namespace Autofac
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<UserService>().AsSelf()
                .EnableClassInterceptors();
            builder.RegisterType<BankService>().As<IBankService>()
                .EnableInterfaceInterceptors();
            builder.RegisterType<StopWatchInterceptor>();
            builder.RegisterType<BankInterceptor>();


            //var service = builder.Build().Resolve<UserService>();
            //service.AddUser("客家皇");
            //service.GetAll();


            var bankService = builder.Build().Resolve<IBankService>();

            foreach (var item in bankService.GetAll())
            {
                Console.WriteLine(item.Name);
            }
            bankService.AddBank(null);

            Console.ReadKey();
        }
    }
}
